<template>
	<view>
		<view class="topbox">
			<view class="sobox">
				<image mode="aspectFill" src="../../static/common/searchicon.png">
					<input placeholder="请输入你要搜索的店铺" @input="searchHotel" placeholder-style="color:#BFBFBF" />
			</view>
		</view>
		<view class="rh-list">
			<view class="rh-list-item" v-for="item in list" @click="detail(item)">
				<view class="cell02">
					<view class="name">{{item.merchantName}}</view>
					<view class="summary"></view>
				</view>
				<view class="cell03 status1">
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			return {
				list: [],
				page: 1,
				isLastPage: false,
				allChecked: false,
				mobile: '',
				orderSelect: ''
			}
		},
		onLoad(option) {
			this.getList();
		},
		methods: {

			detail(item) {
				
				let that = this;
				uni.showModal({
					title: '选择店铺',
					content: '您是否选择属于该店铺',
					confirmText: '确定',
					success(res) {
						if (res.confirm) {
							that.choose();
						}
					}
				})
			},	
			
			choose(){
				let param = {
					id:this.id
				}
				let that = this;
				this.$api.choose(param).then(res => {
				
					if (res.code == 1) {
						that.$util.$showToast("选择成功", '', 'none');
						uni.navigateBack({
							delta:1
						})
					} else {
						that.$util.$showToast(res.msg, '', 'none');
						
					}
				})
			},
			
			searchHotel(e) {
				let value = e.detail.value;
				this.keyword = value;
				this.page = 1;
				this.list = [];
				this.getList();

			},
			getList() {
				let param = {
					page: this.page,
					keyword: this.keyword
				}
				let that = this;
				this.$api.searchShop(param).then(res => {

					if (res.code == 1) {
						let arr = res.data.map(t => ({
							...t,
							isChecked: false
						}))
						let length = arr.length;
						for (let i = 0; i < arr.length; i++) {
							that.list.push(arr[i]);
						}
						if (length < 10) {
							that.isLastPage = true;
						} else {
							that.isLastPage = false;
						}
					} else {}
				})
			}
		}

	}
</script>

<style lang="scss">
	page {
		background: #E1E1E1;
	}

	.topbox {
		background: #FFFFFF;
		padding: 20rpx 30rpx;

		.sobox {
			height: 60rpx;
			line-height: 60rpx;
			display: flex;
			border-radius: 10rpx;
			position: relative;
			background: #F3F4F6;

			input {
				width: 100%;
				text-align: center;
				height: 60rpx;
				line-height: 60rpx;
				font-size: 24rpx;
				color: #333333;
			}

			image {
				width: 48rpx;
				height: 48rpx;
				left: 25%;
				top: 6rpx;
				position: absolute;
			}
		}
	}

	.list-header {
		display: flex;
		padding: 30rpx 30rpx 20rpx 30rpx;

		.left {
			font-size: 28rpx;
			color: #333333;
			flex: auto;
			font-weight: bold;
		}

		.right {
			font-size: 28rpx;
			color: #333333;
		}
	}

	.rh-list {
		.rh-list-item {
			border-radius: 10rpx;
			margin: 20rpx 30rpx 0rpx 30rpx;
			background: #FFFFFF;
			padding: 30rpx;
			display: flex;

			.cell01 {
				margin: 20rpx 30rpx 0 0;

				image {
					width: 38rpx;
					height: 38rpx;
				}
			}

			.cell02 {
				flex: auto;
				margin-right: 30rpx;

				.name {
					font-size: 28rpx;
					color: #333333;
					margin-bottom: 15rpx;
				}

				.summary {
					font-size: 24rpx;
					color: #8E8E8E;
				}
			}

			.cell03 {
				width: 80rpx;
				text-align: right;
				font-size: 26rpx;
			}

			.status1 {
				color: #8e8e8e;
			}

			.status2 {
				color: #E69825;
			}
		}
	}

	.com-bottom-select {
		position: fixed;
		bottom: 0;
		left: 0;
		height: 90rpx;
		line-height: 90rpx;
		width: 84%;
		padding: 0 8%;
		display: flex;
		background: #FFFFFF;

		.left {
			flex: auto;

			image {
				width: 38rpx;
				height: 38rpx;
				vertical-align: middle;
				margin-right: 10rpx;
			}

			text {
				font-size: 28rpx;
				color: #8E8E8E;
				vertical-align: middle;
			}
		}

		.right {
			font-size: 28rpx;
			color: #106DFE;
			vertical-align: middle;
		}
	}
</style>
